package com.example.bilibili.func;

import com.example.bilibili.entity.Buser;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class UResult {
    private BUObj data;

    public static Buser trans(UResult w) {
        Buser buser = new Buser();
        buser.setId(w.getData().getMid())
                .setLevel(w.getData().getLevel())
                .setFace(w.getData().getFace())
                .setName(w.getData().getName())
                .setSex(w.getData().getSex())
                .setFollowing(w.getData().getFollowing())
                .setFollower(w.getData().getFollower())
                .setSign(w.getData().getSign())
                .setGtime(LocalDateTime.now().format(VResult.dtf));

        if (w.getData().getVip() != null) {
            buser.setVip(w.getData().getVip().getLabel().getText());
        }
        return buser;
    }

    public static void setFollow(Buser b, UResult w) {
        b.setFollower(w.getData().getFollower())
                .setFollowing(w.getData().getFollowing());
    }
}

@Data
class BUObj {
    private String mid;
    private String name;
    private String sex;
    private String face;
    private String sign;
    private int level;
    private VIP vip;
    private int following;
    private int follower;
}

@Data
class VIP {
    private Label label;
}

@Data
class Label {
    private String text;
}